home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
apps
/
102
/
examples
/
c_tips.doc
next >
Wrap
Text File
|
1987-01-25
|
12KB
|
341 lines
QUESTION: Is GDOS easy to use?.....ANS...Only if you have docs. & a C compiler!
FACILITIES:520 ST mono vs. 1040 ST color
TOS in ROM vs. TOS in RAM
lowres vs. medres vs. hires
*.PRG vs. *.TOS
no GDOS vs. GEMVDI vers.0.X vs. ATARI GDOS vers.1.1 RESIDENT
PLAN: Copy and install several test cases of the ATARI TOS usage interface from
both MWC and GEM/GDOS documentation. Establish a useful multi-mode text process
for use in Mark Williams C. Do not compare just compilers but learn C in ATARI.
0.0 Binary formats - header of GEM executable code:
( note in ST HACKER - Feb'87 - W. Rostek - p.212 - figure 1 )
601A header: 601A in hex 16 bits
test segment length 32 bits (in hex bytes)
data segment length 32 bits "
bss segment length 32 bits "
symbol table length 32 bits "
0 - 0 32 bits
start address in text seg 32 bits
relocation flag(0,#,ffff) 16 bits
start of text: /* at byte #1c */
n.out header (MWC-68000 format):
struct ldheader {
short l_magic; /* 701a */
short l_flag; /* */
short l_machine; /* */
short l_tbase; /* */
size_t l_ssize[NLSEG]; /* 9 longs */
long l_entry;
}; /* format used in *.o files */
/* start of text at byte #30 */
1.0 "Mark Williams C / ATARI-ST" Mark Williams Co.1986
The program linedemo.tos is copied from the ATARI Explorer dec'86 and is
supplied to illustrate MWC explicitly.
2.0 "Programmer's Guide to GEM" Balma,Fitler SYBEX 1986
The control programs ctrl_ndc.c ( page 157,listing 3.1 ) and ctrl_rc.c(page
158,listing3.2) are basic calling routines, as provided here converted to MWC.
3.0 Examples versus subroutines:
Make stand-alone examples, i.e. EXSHIFT.TOS to demonstrate a give facility.
This then corresponds to the subroutine: shift( # ) . And so forth......
4.0 Verify operations under TOS with or without GDOS:
Test Examples provided for Mark Williams C - 15 Jan'87 - CJPurcell
Cases as tested in lowrez,medrez,and hirez without(not)GDOS or 0.x or1.1 GDOS
Choices: Lowrez Medrez Hirez
PRG TOS PRG TOS PRG TOS
GDOS- not,0.x,1.1;not,0.x,1.1;not,0.x,1.1;not,0.x,1.1;not,0.x,1.1;not,0.x,1.1
cases:
EXBCONIN MWC program - all cases ok.
EXCCONWS MWC program - all cases ok.
EXLINEAC MWC program - .PRG cases ok after ref.code changes as noted. TOS??
EXSHIFT MWC program- ALL CASES OK.
EXTIMDAT MWC program- all cases ok.
RECURSE .TTP - all cases ok.
RECURSEP .TTP - all cases ok.
ST_ALARM : ACCESSORY If clock set: ok and consistant except under GDOS 0.x
drivers:
Use CTRLNDC.C and CTRLRC.C to build test examples for GEM(Consider CTRLMETA.C)
LADYBUG1 GEM program - all cases ok.
LADYBUG2 GEM program - all cases good.
LINEDEMO GEM program - all cases good.
(below: * compile with -VGEM option under MWC * all cases without GDOS fail *)
LINEWALK GEM program -VGEM
almost worked in GDOS 1.1 in mono-except the system crashed at conclusion.
The case in color of LINEWALK.PRG under GDOS v.1.1 worked just fine.
TEXTALGN GEM program -VGEM ok with GDOS fix req'd for color
TEXTEFCT GEM program -VGEM same w/color fix. Fails in .TOS
TEXTSWIS GEM program -VGEM same w/color fix. Fails in .TOS
GETENV (code to provide interface to microCshell from code generated by MWC)
5.0 Basic operations in the microshell MSH.PRG of MarkWilliams C :
bang ops: !operator or ?operator have ranges:
-10 history -1 0 1 - - - - - n where history as is estab.in profile
and n corresponds to the n-th set var
dot ops: correspond to *.BAT files of other systems i.e. . profile
a crucial ^ in-fix char
set environment in . profile or autoload file profile on entry to MSH.PRG
some newly provided options:
EDITOR: useful for installation of LESS.PRG
LESS : options
SSDISK: for single sided disk operations
BINDRIVE : single sided disk applications, as well
cc options (undocumented in manual as supplied):
V.1.0.4 ; -VSRTVC, -VDLINE, -VDTYPE, -VDSYMB, -VKEEP, -VPEEP, -VROM, -VPROF
-VALIEN and I'm told in V.1.1 that -VGEMACC, -VGEMAPP exist.
I can perform -VGEMACC manually, but what is the function of -VGEMAPP ?
help operations - are facilitated by keyclick HELP.TTP then enter -R .
This operation serves to re-establish the HELPFILE index.
*****************selected items as paragraphs for tutorial*********************
source listing of exctime.c :
cc.prg:
#include <types.h>
main()
{
extern char *ctime();
time_t t;
time(&t);
printf(ctime(&t));
}
typical verbose compiler messages from MWC for: exctime.c
Mark Williams C for the Atari ST, Version 1.0.4
Copyright 1984-1986, Mark Williams Co., Chicago.
b:\lib\cpp.prg -o f:\cc12988a exctime.c
a:\lib\cc0.prg D23400000000 f:\cc12988a f:\cc12988b
a:\lib\cc1.prg D23400000000 f:\cc12988b f:\cc12988a
a:\lib\cc2.prg D23400000000 f:\cc12988a exctime.o f:\cc12988b
1 label deleted
rm f:\cc12988a
rm f:\cc12988b
a:\bin\ld.prg -X -d -r a:\lib\crts0.o exctime.o b:\lib\libc.a
Ld: file b:\lib\libc.a: outdated ranlib
a:\lib\gemfix.prg l.out exctime.prg
rm l.out
rm exctime.o
*******************************************************************************
C compiling:
typical declaration conventions used in generic C :
prefix suffix
{ body begin opening (compound statement)
} end closure
&variable_name yields the address of the variable
*name indicates a pointer
name() indicates a function
name[] indicates an array
POINTERS:
case:
typedef char *STRING
is an identifier for pointers to char ; then
STRING name, sign;
means
char *name, *sign;
STRUCTURE declaration:
struct book libry; IS SHORT FOR:
___________________________optional tag_
_________ /
/ struct book {
/ char title[MAXTIT];
TEMPLATE char author[MAXAUT];
\ float value;
\_________ } libry;
\___________________Variable name to template_
PD - private data - made public:
*******************************************************************************
GEM prologs for C programs:
crts0.o :
U main_
00000110 PD errno_
U _stksize_
U _cmdname_
U exit_
U dup2_
00000112 PD environ_
U dup_
U _iovector_
crtsg.o : = crtsggem.o
U main_
00000054 PD errno_
U _stksize_
U exit_
00000056 PD environ_
00000000 SI _start_
crtsg.o(mod) : = crtsgacc.o (= crstd.o in vers. 1.1 of MWC)
00000000 SI _start_
U main_
00000010 bd ustack
00000000 si start
00000810 bd estack
crystal.o :
00000000 PI crystal
0000000C PD ctrl_cn
also see source codes crts0.s , crtsg.s , crystal.s and crtsgacc.s.
*******************************************************************************
LIBRARY FILES:
MWC: libaes.a , libm.a , libc.a , libvdi.a ( as supplied from MW-newdated- )
DRI(used DRTOMW) libf.a , libgem.a ( all on tan msh-support disk-10/27)
libvdibi.a , libaesbi.a , libpan.a ( all newdated )
typically -laes etc will find the guy b:\lib\libaes.a etc.
*******************************************************************************
Comparisons of TOS connective tissue between DRI and MWC.
DRI:
struct _iobuf
{
int _fd; /* file descriptor for low level io */
int _flag; /* stream info flags */
char *_base; /* base of buffer */
char *_ptr; /* current r/w pointer */
int _cnt; /* # chars to be read/have been wrt */
};
extern struct _iobuf _iob[MAXFILES]; /* an array of this info */
#define FILE struct _iobuf /* stream definition */
symbol table from awstart.o ( used drtomw.prg format )
U main_
0000003E SI crystal_
000000A4 PD ctrl_cn_
0000004A SI lnainit_
00000066 SI lnappix_
0000060C bd ustk
00000008 a intinp
0000000C a ptsinp
00000020 a lstlin
00000200 bd savea0
00000208 bd basea0
00000204 bd savea1
MWC:
typedef struct FILE {
unsigned char *_cp, /* current character ptr */
*_dp, /* ptr to start of data in buffer */
*_bp; /* buffer pointer */
int _cc; /* character count */
int (*_gt)(), /* getc function */
(*_pt)(); /* putc function */
char _ff; /* flags; see below */
char _fd; /* file descriptor (reqd by reopen) */
int _uc; /* ungot char */
} FILE;
symbol table from crts0.o
U main_
00000110 PD errno_
U _stksize_
U _cmdname_
U exit_
U dup2_
00000112 PD environ_
U dup_
U _iovector_
00000000 SI _start_
PROFILE my busy version of . profile for use in initializing MSH.PRG :
set drive1=a:
set drive2=b:
set drive4=f:
setenv PATH=.bin,,$drive1\bin,$drive2,$drive2\bin
setenv SUFF=,.prg,.tos,.ttp,.app
setenv LIBPATH=$drive1\lib,$drive2\lib
setenv TMPDIR=$drive4
setenv INCDIR=$drive2\include
setenv TIMEZONE=CST:0
setenv LESS=-pm
setenv EDITOR=editor.ttp
set prompt='>> '
set history=10
set a='ddir a:'
set b='ddir b:'
set c='cc -V'
set cg='cc -V -VGEM'
set d='dumpa s'
set e='editor'
set h='set in history'
set l='list'
set m='less -m'
set n='nm -ap'
set o='help overview'
set p='dirb'
set q='. exit_mwc'
set r='ar tv'
set s='stty003.ttp'
set t='b:\less.txt'
set u='list b:\usage.txt'
set x='b:\me_mwc.ttp'
set z='as -l'
blufont
echo ' mshell.tos <Mark Williams microShell> <LOGIKRON colortlk.prg> '
echo ' welcome Charles Purcell ; ; - 321K FASTRM12.PRG installed - '
echo ' '
echo ' !bang ops?!a-ddir-b !c cc-V !d dumpa !e editor !h hist. !g cc-V-VGEM'
echo ' !l list !m less -m !n nm -ap !o overview !p dirb !q . quit = . script'
echo ' !r ar tv(b:\lib\) !s stty003 !t b:\less.txt !u help !x me_mwc !z as -l '
echo ' !v listing pr !w it out >prn '
echo ' !m less>more, but, more>list !l try !m !t for demonstration '
echo ' '
echo ' ***microshell files*** '
echo *.c
echo *.prg
echo *.tos
echo *.txt
echo b:\*.txt
date
echo ' ***system freespace*** '
mf
df -a